package com.lesso.lll.sunflower.attendance.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 考勤规则控制器
 */
@RestController
@RequestMapping("/api/rule")
@Api(tags = "AttendanceRuleController", description = "考勤规则管理")
public class AttendanceRuleController {

    @Autowired
    private AttendanceRuleService ruleService;

    @ApiOperation("新增考勤规则")
    @PostMapping("/add")
    public CommonResult<Long> addRule(@RequestBody AttendanceRule rule) {
        Long ruleId = ruleService.addRule(rule);
        return CommonResult.success(ruleId);
    }

    @ApiOperation("修改考勤规则")
    @PostMapping("/update")
    public CommonResult<Boolean> updateRule(@RequestBody AttendanceRule rule) {
        boolean result = ruleService.updateRule(rule);
        return CommonResult.success(result);
    }

    @ApiOperation("删除考勤规则")
    @PostMapping("/delete/{ruleId}")
    public CommonResult<Boolean> deleteRule(@PathVariable Long ruleId) {
        boolean result = ruleService.deleteRule(ruleId);
        return CommonResult.success(result);
    }
}    